﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Runtime.Serialization;
using System.ServiceModel;
using System.Text;
using LuxuryResort.BIZ;
using LuxuryReport.DataService.Mapping;

namespace LuxuryReport.DataService
{
    // NOTE: You can use the "Rename" command on the "Refactor" menu to change the class name "Service1" in both code and config file together.
    public class RoomService : IRoomService
    {
        private IRoomBiz _iRoomBiz = new RoomBiz();
        private IReservationBiz _reservationBiz = new ReservationBiz();
        private IFoodOrderBiz _orderBiz = new FoodOrderBiz();

        public List<Mapping.Room> GetRooms()
        {
            var rooms = _iRoomBiz.GetRooms().OrderBy(x => x.RoomNo);
            
            var lst = new List<Mapping.Room>();
            
            foreach(LuxuryResort.Entity.Room efRoom in rooms)
            {
                lst.Add(Mapping.Room.MapToRoom(efRoom));
            }
            return lst;
        }

        public Mapping.Room GetRoom(Guid roomId)
        {
            var efRoom = _iRoomBiz.GetRoom(roomId);
            return Mapping.Room.MapToRoom(efRoom);
        }

        public void BookRoom(Mapping.Reservation r)
        {
            var reservation = Mapping.Reservation.MapToReservation(r);
            _reservationBiz.BookRoom(reservation);
        }

        public void OrderFood(List<Mapping.FoodOrder> fos)
        {
            var lst = new List<LuxuryResort.Entity.Food_Beverage_Order>();
            foreach (Mapping.FoodOrder order in fos)
            {
                lst.Add(Mapping.FoodOrder.MapToFoodOrder(order));
            }

            _orderBiz.OrderFood(lst);
        }

        
    }
}
